package acm.pta7;

import java.util.Scanner;

public class T6 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String c = sc.next();
        int n = sc.nextInt();
        String[] origin=new String[n];
        StringBuilder old=new StringBuilder();
        sc.nextLine();
        for (int i = 0; i < origin.length; i++) {
            origin[i]=sc.nextLine();
            old.append(origin[i]).append("\n");
        }
        StringBuilder builder=new StringBuilder();
        for (int i = origin.length - 1; i >= 0; i--) {
            fun(origin[i],builder);
            builder.append("\n");
        }
        String oldStr = old.toString();
        String newStr = builder.toString();
        String res = newStr.replace("@",c);
        if (oldStr.equals(newStr)){
            System.out.println("bu yong dao le");
            System.out.print(res);
        }else{
            System.out.print(res);
        }
    }
    public static void fun(String str,StringBuilder builder){
        for (int i = str.length()-1; i >= 0; i--) {
            builder.append(str.charAt(i));
        }
    }
}
